package com.online.service;

import com.online.dao.AnswerMapper;
import com.online.entity.Answer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AnswerServiceImpl implements AnswerService {

    @Autowired
    AnswerMapper answerMapper;


    @Override
    public int addAnswer(String answerContent, int answerType, int questionId, String answerkeys) {
        //插入答案
        Answer answer = new Answer();
        answer.setAnswerContent(answerContent);
        answer.setAnswerType(answerType);
        answer.setQuestionId(questionId);
        answer.setAnswerKeys(answerkeys);

        return answerMapper.addAnswer(answer);
    }

    @Override
    public Answer showAAnswer(Integer answerType, Integer questionId) {
        return answerMapper.selectAnswer(answerType,questionId);
    }

    @Override
    public int deleteAnswer(Integer questionId, Integer answerType) {
        return answerMapper.deleteAnswer(questionId,answerType);
    }
}
